// 声明变量 联合类型
let phone:number | string = 13400110011 || "0591-88888888"

let fn01 = function(type:number | boolean):boolean {
  return !!type
}

let result01 = fn01(1)

console.log(result01)

// 类型断言
interface People {
  name: string
  age: number
}

interface Man {
  sex: number
}

const xiaoSun = (man: People & Man):void => {
  console.log(man)
}

xiaoSun({
  name: 'xiaosun',
  age: 18,
  sex: 1
})

// 交叉类型
let fn02 = function (num:number | string):void {
  console.log((num as string).length)
}

fn02("67890123456") // 11
// fn02(67890123456) // undefined

interface A {
  run: string
}

interface B {
  build: string
}

let fn03 = (type:A | B):void => {
  // console.log((<A>type).run)
  console.log((type as A).run)
}

fn03({
  run: '12123231',
  // build: '123'
})

// (window as any).abc = 123

const fn04 = (type:any):boolean => {
  return type as boolean
}

fn04(123)
